package com.stormdemo.topn;

import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.topology.TopologyBuilder;
import backtype.storm.tuple.Fields;

import com.stormdemo.topn.bolt.PrintBolt;
import com.stormdemo.topn.bolt.WordCountBolt;
import com.stormdemo.topn.bolt.transfBolt;
import com.stormdemo.topn.spout.RandomWordSpout;

public class touplemain {
	private static TopologyBuilder builder = new TopologyBuilder();

	public static void main(String[] args) {
		builder.setSpout("random", new RandomWordSpout(),2);
		builder.setBolt("transf", new transfBolt(),4).shuffleGrouping("random");
		builder.setBolt("wc", new WordCountBolt(),1).fieldsGrouping("transf", new Fields("transf"));
		/*builder.setBolt("print", new PrintBolt(),4).shuffleGrouping("wc");*/
		
		Config conf = new Config();
		conf.setDebug(false);
		//conf.setMaxTaskParallelism(1);
		LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("wordcount", conf, builder.createTopology());
	}
}
